﻿
/**
 * A Gamestate is the most important class in this framework.
 * It is responsible for the game's logic at a certain point/range in time.
 * Normally there would be a gamestate for the main menu, the credits, the actual game, etc...
 */
class MyGamestate
	: GameState
{
	/**
	 * This function is called by the engine when the gamestate becomes active (ie. through
	 * a call to setGamestate).
	 */
	void activated(Game@ game)
	{
		// Let's spawn an entity that represents the camera of the player
		@m_camera = game.entitySystem.createEntity();
		m_camera.attach(PositionComponent());
		CameraComponent@ camera = game.entitySystem.cameraComponent;
		m_camera.attach(camera);
	}

	/**
	 * This function is called by the engine when the gamestate becomes inactive (ie. another
	 * gamestate has been set as the current gamestate).
	 */
	void deactivated(Game@ game)
	{
		game.entitySystem.destroyEntity(m_camera);
		@m_camera = null;
	}



	/**
	 * This function is called by the engine once per frame to update the actual game logic.
	 */
	void update(Game@ game)
	{
		//engine.entitySystem
	}

	Entity@   m_camera;
};
///////////////////////////////////////////////////////////////////////////////////////////////////




/**
 * Constructor of the Game implementation.
 * This is the right point to initialize objects AND to set the first gamestate that
 * shall be used by the engine.
 */
void init(Game@ game)
{
	string tmp1 = "Hello World!";
	string tmp2 = "I'm unicoded: \u20AC";

	// Begin the actual game by setting the first gamestate
	MyGamestate gs;
	game.setGamestate(gs);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
